/*
 * Author: Reynier Ortiz
 * Date: Nov 9, 2013
 */

$(function () {
    var errorMsgContainer = $("div[id*=errorMessageContainer]");
    var errorMsg = $("span[id*=errorMessage]");
    var roleId = $("input[id*=inputRoleId]").val();
    var roleDropdown = $("select[id*=inputRole]");
    var userId = $("input[id*=inputUserId]").val();
    
    if (userId && userId > 0) {
        var lblPassword = $("label[id*=labelPassword]");
        var inputPassword = $("input[id*=inputPassword]");
        lblPassword.addClass("text-muted");
        inputPassword.addClass("disabled");
        lblPassword.attr("disabled", "disabled");
        inputPassword.attr("disabled", "disabled");
    }
        
    if (errorMsg.text()) errorMsgContainer.show();
    
    if (roleId) {
        switch (roleId) {
            case "3": roleDropdown.val("ADMIN");
                break;
            case "2": roleDropdown.val("PROF");
                break;
            case "1": roleDropdown.val("STUD");
                break;
        }
    }
});
